﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using context;
using entity;
using DataObject;

namespace HR_Implements
{
   public class EmployeeRemotingObject:MarshalByRefObject,HR_Interfaces.IEmployeeRemotingObject
    {
        context.HRDataContext ctx = new HRDataContext();
        public List<EmployeeEntity> GetAllEmployees()
        {
            List<EmployeeEntity> emp_list = null;
            var q = from e in ctx.Employees
                    select new EmployeeEntity()
                    {
                        EmployeeCode = e.cEmployeeCode,
                        FirstName = e.vFirstName,
                        LastName = e.vLastName,
                        Address = e.vAddress
                    };
             emp_list = q.ToList();
             return emp_list;
        }

        public List<EmployeeEntity> SearchEmployeesByQualification(string qualification)
        {
            List<EmployeeEntity> emp_list = null;
            var q = from e in ctx.Employees
                    where e.vQualification == qualification
                    select new EmployeeEntity()
                    {
                        EmployeeCode = e.cEmployeeCode,
                        FirstName = e.vFirstName,
                        LastName = e.vLastName,
                        Address = e.vAddress
                    };
            emp_list = q.ToList();
            return emp_list;
        }
    }
}
